package com.cy7;

import java.util.Objects;

/**
 * 测试toString与HashCode的练习
 *
 * @author CY
 * @date 2022/08/06 22:45
 **/
public class Test2 {
    public void fun(){
        System.out.println("我是爸爸1号！");
    }
    protected int fun(int a){
        System.out.println("我是爸爸2号！");
        return 0;
    }

    public static void main(String[] args) {
        Test2 test2 = new Test2();
        test2.fun();
        test2.fun(1);
//        test2.fun(3.0);

    }
}
class Test3 extends Test2{
    @Override
    protected int fun(int a) {
        System.out.println("我是儿子，重写了父类2号！");
        return 0;
    }

    void fun(double c){
        System.out.println("我是儿子一号！");
    }

    public static void main(String[] args) {
        Test3 test3 = new Test3();
        float f=3.0f;
        test3.fun(f);
        test3.fun();
        test3.fun(1);
    }
}
class Test4 extends Test2{
    @Override
    protected int fun(int a) {
        System.out.println("我是干儿子，重写了父类2号！");
        return 0;
    }
}
class TestDemo{
    public static void Demo (Test2 demo){
        demo.fun(3);
    }
    public static void main(String[] args) {
        Test2 demo1=new Test3();
        Test2 demo2=new Test4();
        Demo(demo1);
        Demo(demo2);

    }
}
